#region Imported Namespaces



using System;
using System.Collections.ObjectModel;



#endregion


namespace WtfManager.Framework
{
  ///<summary>
  /// Represents and manipulates a collection of modules.
  ///</summary>
  public class ModulesCollection: ObservableCollection<Module>
  {
    #region Properties/Indexers



    ///<summary>
    /// Gets a <see cref="Module"/> by its name.
    ///</summary>
    ///<param name="name">The name of a <see cref="Module"/> to get.</param>
    public Module this[string name]
    {
      get
      {
        foreach (Module module in this)
        {
          if (module.Name.Equals(name))
            return module;
        }

        return null;
      }
    }


    ///<summary>
    /// Gets a <see cref="Module"/> by its type.
    ///</summary>
    ///<param name="type">The type of a <see cref="Module"/> to get.</param>
    public Module this[Type type]
    {
      get
      {
        foreach (Module module in this)
        {
          if (module.GetType() == type)
            return module;
        }

        return null;
      }
    }



    #endregion
  }
}